<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <style>
        body{
            color: red;
        }
        ul{
            color: blue;
        }
        li{
            color: yellow;
        }
        a{
            color: inherit;
        }
    </style>
</head>
<body>
    <ul>
        <li><a href="">123123</a></li>
    </ul>
</body>
<script>
   /*  function fn(){
        console.log(this); // window
    }
    fn();

    var zhang = {
        name:"张三",
        age:18,
        say:function(){
            console.log(this);
            console.log(this.name,this.age);
        }
    }

    zhang.say();   // this -> zhang


    document.onclick = function(){
        console.log(this); // document
    } */


    // 箭头函数没有自己的this指向,它的this依赖于箭头函数所在作用域(父作用域的this指向) 简单的来说 箭头函数遇到this就向外跳一层 找父作用域的this指向,如果父作用域也是箭头函数,继续向外跳一层,依次类推,直到全局作用域(this -> window)

    var fn = () => {
        console.log(this); // window
    }
    fn();


    var zhang = {
        name:"张三",
        age:18,
        say:()=>{
            console.log(this);    // this -> window
            console.log(this.name,this.age);
        }
    }

    // zhang.say();  
    

    document.onclick = () => {
        console.log(this); // window
    } 



</script>
</html>